import { Component,OnInit } from '@angular/core';
import { Hero } from './hero';
import { HeroService } from './hero.service';
import { Router } from '@angular/router';
import { HeroSearchComponent } from './hero-search.component';

@Component({
    selector:'my-dashbodard',
    templateUrl : `app/dashboard.component.html`,
    styleUrls:['app/dashboard.component.css'],
    directives: [HeroSearchComponent] 
})
export /**
 * DashboardComponent
 */
class DashboardComponent implements OnInit {
    constructor(private heroService:HeroService,private router:Router){

    }
    heroes:Hero[]=[];
    gotoDetail(hero:Hero){
        let link =['/detail',hero.id];
        this.router.navigate(link);
    }
    ngOnInit(){
        this.heroService.getHeroes()
            .then(heroes=>this.heroes=heroes.slice(1,5))
    }
    

}